<?php 
require_once('includes/functions.php');
connectlogin();
/// Make sure that a value was sent.
if (isset($_GET['search']) && $_GET['search'] != '') {

	// Add slashes / escape string to avoid SQL problems / injections.
	$search = mysql_real_escape_string(trim(addslashes($_GET['search'])));

	// Get every page title for the site.
		
	$sql = "SELECT distinct name as suggest, id, fname, lname FROM account_data WHERE name LIKE '" . $search . "%' or fname LIKE '" . $search . "%' or lname LIKE '" . $search . "%' ORDER BY name LIMIT 0, 5";
	
	$suggest_query = mysql_query($sql);
	
	$count = mysql_num_rows($suggest_query);
	
	if($count == 0){
	
		echo "<div class='suggestions' style='color: #08c;'>No suggestions</div>\n";
	
	} else { // Display suggestions found.
	
		echo "<div class='suggestions''>Suggestions</div>\n";
		
		while($suggest = mysql_fetch_array($suggest_query)) {
			//Return each page title seperated by a newline.
			echo "<div class='suggest_link'><a href='user_edit.php?uid=" . $suggest['id'] . "'>" . $suggest['suggest'] . "</a></div>\n";
		}
		
	}
}
?>